package com.xmg.day01;

import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TransferQueue;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Day01_transferQueue {
    Thread t1,t2;

    public static void main(String[] args) {

        char[] aI = "123456".toCharArray();
        char[] aC = "ABCDEF".toCharArray();

        TransferQueue<Character> queue = new LinkedTransferQueue<>();

        new Thread(()->{
            try {
                for (char c : aI) {
                    System.out.print(queue.take());
                    queue.transfer(c);
                }
            }catch (Exception e){

            }
        }).start();

        new Thread(()->{
            try {
                for (char c : aC) {
                    queue.transfer(c);
                    System.out.print(queue.take());
                }
            }catch (InterruptedException e){

            }
        }).start();
    }
}
